// Sculpture.h
#ifndef __CS148_Sculpture_H__
#define __CS148_Sculpture_H__

#include "st.h"
using namespace std;

struct TourInfo
{
    // Information about the tour.
        // tours[1] would have tour info from the 2nd tour site to the
        // 3rd tour site
        //0: distance,
        //1: time in milliseconds
        //2,3,4 = x y z of the slope vector
    float distance;
    float time;
    float dx;
    float dy;
    float dz;
    int increments; // for drawing the path
};

enum TourDirection
{
    D_FORWARD,
    D_STOP,
    D_BACKWARD,
    //D_WAIT,  //Waiting for command input stuff to finish
};

class Sculpture
{
public:
    void Update(float CurrentTimeInSeconds);
    void Setup();
    void Draw();
    void DrawSecondary();
	void SetDiffuseColor(float r, float g, float b);
	void SetSpecularColor(float r, float g, float b);

    void AdjustCameraPosition(float x, float y, float z);
    void SetCameraPosition(float x, float y, float z);
    vector<float> GetCameraPosition();
    float GetControlPointOffset();
    void AdjustCameraAngle(float pitch, float yaw);
    void SetCameraAngle(float pitch, float yaw);
	
	void SetFree();
	int GetFree();
    
    void SetFPP(); //set first person perspective

	void SetRingRadius(float r);
	void SetCFile(char * cfile);
    char * GetCFile();
	void SetSFile(char * sfile);
	void SetTFile(char * tfile);
	void SetVFile(char * vfile);

	void SetWindow1(int win);
	void SetWindow2(int win);
	void PrintCurrentStats();

	void SetState(TourDirection td);

	void AddTourSite(float, float y, float z);
	void RemoveTourSite(int index);
    int GetCurrentTourStep();
    vector<vector<float> > GetTourSites();
	vector<vector<float> > GetUnvisitedTourSites();
    void TourSetup();
private:
    //
    // Parameters of the user-controlled camera.
    //
    void PrintInitialStats();
    void parseLine(string line);
    void parseTourLine(string line);
	void parseTriLine(string line);
    void parseControlLine(string line);
    void PrintEdge(vector<int> edge);

    void ReadMap();
    void ReadTourInfo();
    void RenderPath();
    void RenderSites();
    void RenderMe();
    void RenderMap();

    // An array of vertices. Every vertex is a 3-element integer array
    vector<vector<int> > sites;

    // An array of tour sites. Each site represent a <x,y,z>
    // location thatwe must visit during the tour.
    vector<vector<float> > tour_sites;

    // Edges. Each edge is a <src, dst> pair where src and dst
    // are indices to the 'sites' array.
    vector<vector<int> > edges;

	vector<vector<int> > triangles;
    // The Bezier control points. The polar coordinates are stored as follows:
    // (0,0)
    // (0,1)
    // (1,1)
    // (1,2)
    // (2,2)
    // etc
    vector<vector<float> > ctrls;
    // Information about the tour.
    // tours[1] would have tour info from the 2nd tour site to the
    // 3rd tour site
    //0: distance,
    //1: time in milliseconds
    //2,3,4 = x y z of the slope vector
    //vector<TourInfo > tours;

    vector<float> mCamTrans;
    float mCameraAzimuth;
    float mCameraElevation;
    float mYaw; //primary camera's yaw
    float mPitch; //primary camera's pitch
    float mOYaw;
    float mOPitch;
    int mChanged;
    int mCTS; // Current tour step
    float mCTSST;  // Current tour step start time
	int mCPO; //Current control point offset.
	//float mCPST; //Current control point set start time
    float mVelocity; // Velocity in units per second
	//
	// Current time in milliseconds
	//
	float mCurrentTime;
    float mCurrentCurveD;
    int mFree, mFPP, mCamInterval;
    float mRingRadius;
    GLUquadricObj *mQuadric;
    GLUnurbs *mCurve;
    char *mCFile, *mSFile, *mVFile, *mTFile;

    int mWin1, mWin2; //ID of primary and secondary window;
    int mStop, mForward, mBackward; //stop, forward, backwards in the tour
    TourDirection mDir;
    float mParamT;
};

#endif // __CS148_Sculpture_H__
